/**
 * Created by zhufe on 2017/12/13.
 */

var thisUrl = window.location.href
// var server = "http://101.37.21.21:8023/wx/";
var server = "http://localhost:8020/wx/";
function loadPage(url){
    $.ajax({
        type:'Get',
        url:url,
        dataType:'html',
        async:false,
        success:function (msg) {
            document.write(msg)
        }
    });
}
function getUrlParams(url) {
    var theUrl = url ? url : location.href;
    var splitUrl = theUrl.split('?'),
        paramPart = splitUrl[splitUrl.length - 1],
        paramsArr = paramPart.split('&');
    var params = {};
    if (splitUrl.length > 1) {
        for (var i = 0, l = paramsArr.length, param, name, val; i < l; i++) {
            param = paramsArr[i].split('=');
            name = param[0];
            val = param[1];
            if (val.indexOf('#') !== -1) {
                val = param[1].split('#')[0];
            }
            if (typeof name === 'string' && name !== '') {
                if (params[name]) {
                    if (typeof params[name] === 'string') {
                        params[name] = [params[name]];
                    }
                    params[name].push(val);
                } else {
                    params[name] = val;
                }
            }
        }
    }

    return params;
}
$().ready(function() {
    <!-- 自定义filter名称为'time' -->
    Vue.filter('time',
        <!-- value 格式为13位unix时间戳 -->
        <!-- 10位unix时间戳可通过value*1000转换为13位格式 -->
        function(value) {
            var date = new Date(value);
            Y = date.getFullYear(),
                m = date.getMonth() + 1,
                d = date.getDate(),
                H = date.getHours(),
                i = date.getMinutes(),
                s = date.getSeconds();
            if (m < 10) {
                m = '0' + m;
            }
            if (d < 10) {
                d = '0' + d;
            }
            if (H < 10) {
                H = '0' + H;
            }
            if (i < 10) {
                i = '0' + i;
            }
            if (s < 10) {
                s = '0' + s;
            }
            <!-- 获取时间格式 2017-01-03 10:13:48 -->
            var t = Y+'-'+m+'-'+d+' '+H+':'+i+':'+s;
            <!-- 获取时间格式 2017-01-03 -->
            // var t = Y + '-' + m + '-' + d;
            return t;
        });
});
var vue = "";
var app = {
     login: function (data, name) {
        console.log(data);
        axios.post(server + 'manager/login', data).then(function (response) {
            // alert(response.data);
            console.log(response)
            if (response.data.returnCode == 1) {
                setCookie("user", name);
                setCookie("adminId",1);
                console.log(getCookie("user"))
                window.location = "http://101.37.21.21:8023/front/html/index.html";
            } else {
                alert(response.data.errMsg)
            }

        }).catch(function (error) {
            alert(error);
        });
    },
};